package com.zy.control;

import com.zy.entity.BaseResponse;
import com.zy.entity.Book;
import com.zy.entity.Person;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ZY
 * @describe
 * @date 2020/8/27
 */
@RestController
@Api(value = "/swaggertest", description = "专门用于测试swagger",tags = "Swagger测试")
@RequestMapping("/swaggertest")
@Slf4j
public class SwaggerTestControl {



    @GetMapping("/v1/response")
    @ApiOperation(value = "返回值", notes = "返回值格式测试",httpMethod = "GET")
    public BaseResponse<Person> response() {


        return BaseResponse.<Person>builder().data(Person.builder().pName("aa").build()).build();
    }


    @GetMapping("/v1/responses")
    @ApiOperation(value = "返回值多个", notes = "返回值格式测试",httpMethod = "GET")
    public BaseResponse<List<Person>> responses() {
        Person person = Person.builder().pName("aa").build();
        List<Person> personList = new ArrayList<>();
        personList.add(person);
        return BaseResponse.<List<Person>>builder().data(personList).build();
    }












}
